<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <div onclick=""></div>
  </div>


  <script>
    // for in key是索引
    /* var a = ['a', 'b', 'c']
    for (let i in a) {
      console.log('in', i)
    }
    // 是元素项
    for (let item of a) {
      console.log('of', item)
    } */

    // for in可以循环对象，而 for of不可以循环对象
    var a = {id:1,name:'abc'}
    for(let key in a){
      console.log(key)
    }

    // 报错
    /* for(let item of a){
      console.log(item)
    } */
    // 把对象转为数组 Object.entries(a)   Object.keys()  Object.values()
    // console.log(Object.entries(a))
    for(let item of Object.entries(a)){
      console.log(item)
    }

    // 解构赋值
    /* let arr = ["id", 1]
    let [aa,bb] = arr
    console.log(aa,bb) */

    for(let [aa,bb] of Object.entries(a)){
      console.log(aa,bb)
    }


  </script>
</body>

</html>